/**
 * Common/Menu.qml se chua nhieu MenuDelegate( icon,ten )
 *
 */
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import "../common"

import org.qtproject.znews_qt 1.0

Item {
    id:id_item;

    height: 70 *m_ratio
    width: parent.width;
    property real m_ratio : ApplicationInfo.ratio
    property string m_icon: "value"
    property string m_name: "name"
    property int m_id: 0 // id_menu tuong ung  dung de goi ra ngoai

    //signal
    signal clicked(int idMenudelegate, int index);

    RowLayout {
        id: row1
        anchors.fill: parent
        spacing: 10 * m_ratio;


        Item{
            id: item1
            anchors.fill: parent

            Image {
                id: id_icon
                source: m_icon
                height: row1.height;
                width: height;

            }

            Text{
                id:id_name ;
                anchors.top: parent.top
                anchors.bottom: parent.bottom
                anchors.right: parent.right
                anchors.left: id_icon.right
                anchors.leftMargin: 5
                text: m_name;
                wrapMode: Text.WordWrap
                verticalAlignment: Text.AlignVCenter
                font.pixelSize: 20 * m_ratio

            }

        }

    }


    Rectangle {
        width: id_item.width; height: 1; color: "#cccccc"
        anchors.top: id_item.bottom
        visible: id_item.ListView.isCurrentItem ? false : true
    }

    Rectangle {
        width: id_item.width; height: 1; color: "white"
         anchors.top: id_item.bottom
        visible: id_item.ListView.isCurrentItem ? false : true
    }


    MouseArea{
        anchors.fill: id_item
        onClicked: {
            id_item.ListView.view.currentIndex = index
            console.log("onclicked " + index)
            id_item.clicked(m_id, index);
        }
        onEntered: {
            console.log("on enter")
        }
        onExited: {
            console.log("on exit")
        }
    }
}
